<template>
  <div>
    <el-row>
      <el-col :span="24">
        <el-table :data="tableData" v-loading="tableConfig.load" :style="tableConfig.style" :max-height="tableConfig.maxHeight" :border=tableConfig.border :size="tableConfig.size" @selection-change="handleSelectionChange">
          <template v-for="(item, index) of tableConfig.config">
            <el-table-column v-if="item.id === 'operation'" :key="index" :prop="item.id" :label="item.name" :align="tableConfig.align?tableConfig.align:'center'" :width="item.width">
              <template slot-scope="scope"> <el-button v-for="n in item.list" :key="n.id" @click="examine(scope.row, n.id, scope.$index)" type="text" size="small" :class="n.className">{{n.name}}</el-button> </template>
            </el-table-column>
            <el-table-column v-else :label="item.name" :key="index" :prop="item.id" :align="tableConfig.align?tableConfig.align:'center'" :width="item.width" :type="item.type"></el-table-column>
          </template>
        </el-table>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'tableList',
  props: ['tableConfig', 'tableData'],
  methods: {
    examine (rows, id, index) {
      this.$emit('operation', {id: id, rows: rows, index: index})
    },
    handleSelectionChange (val) {
      this.$emit('handleSelectionChange', {val: val})
    }
  }
}
</script>
